<?php if(Yii::app()->user->hasFlash('commentSubmitted')): ?>
<div class="form">
<?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>
</div>
<?php return; endif; ?>

<div class="form">
  <form action="<?php echo CHtml::normalizeUrl(array($post->id)).'#leave_comment';?>" method="post">

<?php echo CHtml::errorSummary($comment); ?>

<div class="row">
<?php echo CHtml::activeLabel($comment,'author'); ?>
<?php echo CHtml::activeTextField($comment,'author',array('size'=>65,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo CHtml::activeLabel($comment,'email'); ?>
<?php echo CHtml::activeTextField($comment,'email',array('size'=>65,'maxlength'=>128)); ?>
<p class="hint">
Tu e-mail no ser&aacute; publicado.
</p>
</div>
<div class="row">
<?php echo CHtml::activeLabel($comment,'url'); ?>
<?php echo CHtml::activeTextField($comment,'url',array('size'=>65,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo CHtml::activeLabel($comment,'content'); ?>
<?php echo CHtml::activeTextArea($comment,'content',array('rows'=>6, 'cols'=>50)); ?>
<p class="hint">
Puedes usar la sintaxis <a href="http://daringfireball.net/projects/markdown/syntax" target="_blank">Markdown</a>.
</p>
</div>

<?php if(Yii::app()->user->isGuest && extension_loaded('gd')): ?>
<div class="row">
	<?php echo CHtml::activeLabel($comment,'verifyCode'); ?>
	<div>
	<?php $this->widget('CCaptcha'); ?>
	<?php echo CHtml::activeTextField($comment,'verifyCode'); ?>
	</div>
	<p class="hint">Escribe las letras que aparecen en la im&aacute;gen de arriba.</p>
</div>
<?php endif; ?>

<div class="row action">
<?php echo CHtml::submitButton($update ? 'Modificar comentario' : 'Añadir comentario', array('name'=>'submitComment')); ?>

<?php echo CHtml::submitButton('Vista previa',array('name'=>'previewComment')); ?>
</div>

  </form>
</div><!-- form -->

<?php if(isset($_POST['previewComment']) && !$comment->hasErrors()): ?>
<h3>Vista previa</h3>
<div class="comment">
  <div class="author"><?php echo $comment->authorLink; ?> ha dicho:</div>
  <div class="time"><?php echo Yii::app()->dateFormatter->formatDateTime($comment->createTime,'long','short'); ?></div>
  <div class="content"><?php echo $comment->contentDisplay; ?></div>
</div><!-- post preview -->
<?php endif; ?>